package app.beit.fintrack.service.convert;

import java.util.ArrayList;
import java.util.List;

import app.beit.fintrack.bean.ProvinceBean;
import app.beit.fintrack.entity.Province;

public class ProvinceConvert {

	/**
	 * Convert Entity To Bean
	 * 
	 * @param entity
	 * @return ProvinceBean
	 */
	public static ProvinceBean entityToBean(final Province entity) {
		final ProvinceBean bean = new ProvinceBean();

		bean.setProvinceCode(entity.getProvinceCode());
		bean.setProvinceName(entity.getProvinceName());

		return bean;
	}

	/**
	 * Convert Bean to Entity
	 * 
	 * @param bean
	 * @return Province
	 */
	public static Province beanToEntity(final ProvinceBean bean){
		final Province entity = new Province();

		entity.setProvinceCode(bean.getProvinceCode());
		entity.setProvinceName(bean.getProvinceName());

		return entity;
	}

	/**
	 * Convert List Entity to List Bean
	 * 
	 * @param entities
	 * @return List ProvinceBean
	 */
	public static List<ProvinceBean> entityToBean(final List<Province> entities){
		final List<ProvinceBean> beans = new ArrayList<ProvinceBean>();

		for (final Province entity : entities) {
			beans.add(ProvinceConvert.entityToBean(entity));
		}

		return beans;
	}

	/**
	 * Convert List Bean to List Entity
	 * 
	 * @param beans
	 * @return List Province
	 */
	public static List<Province> beanToEntity(final List<ProvinceBean> beans){
		final List<Province> entities = new ArrayList<Province>();

		for (final ProvinceBean bean : beans) {
			entities.add(ProvinceConvert.beanToEntity(bean));
		}

		return entities;
	}

}
